package com.chanceit.ssss.adapters;

import android.app.Activity;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.chanceit.ssss.activity.R;
import com.chanceit.ssss.fragments.MessageCenterComplaintListFragment;
import com.chanceit.ssss.fragments.MessageCenterOrderListFragment;

public class MessageCenterPagerAdapter extends FragmentStatePagerAdapter {
	Activity context;
	String tabs[] = new String[3];
	Fragment[] fagments = new Fragment[tabs.length];

	public MessageCenterPagerAdapter(FragmentManager fm, Activity context) {
		super(fm);
		this.context = context;
//		tabs = new String[] {
//				context.getString(R.string.messagecenter_communication),
//				context.getString(R.string.messagecenter_order),
//				context.getString(R.string.messagecenter_complain) };
		tabs = new String[] {
				context.getString(R.string.messagecenter_order),
				context.getString(R.string.messagecenter_complain) };
	}

	@Override
	public Fragment getItem(int position) {
		// getItem is called to instantiate the fragment for the given page.
		// Return a DummySectionFragment (defined as a static inner class
		// below) with the page number as its lone argument.
		// Fragment fragment = new HjFragment();
		// Bundle args = new Bundle();
		// args.putInt("no", position + 1);
		// fragment.setArguments(args);
		Fragment fragment = fagments[position];
		if (fragment == null) {
			switch (position) {
			case 1:
				fragment = new MessageCenterComplaintListFragment();
				fagments[position] = fragment;
				break;
			case 0:
				fragment = new MessageCenterOrderListFragment();
				fagments[position] = fragment;
				break;
//			case 0:
//				fragment = new MessageCenterMessageListFragment();
//				fagments[position] = fragment;
//				break;
//			default:
//				fragment = new MessageCenterMessageListFragment();
//				fagments[position] = fragment;
//				break;
			}
		}
		return fragment;
	}

	@Override
	public int getCount() {
		// Show 3 total pages.
		return tabs.length;
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return tabs[position];
	}
}